day 14 - Tiny Runes [general]

day 14 - Tiny Runes

One of Santa's Little Helpers received an unusual Christmas wish, a copy of the yet to be released Deus Hex game. All they managed to find were fragments from the dialogue system. Can you decode the last one?

Recon

We are provided the following files:

-rw-r--r--   1 spotless  spotless   965 Nov 29 00:17 lines1.bin
-rw-r--r--   1 spotless  spotless   399 Nov 29 20:55 lines1.png
-rw-r--r--   1 spotless  spotless    74 Nov 26 01:30 lines1.txt
-rw-r--r--   1 spotless  spotless  1161 Nov 29 00:45 lines2.bin
-rw-r--r--   1 spotless  spotless   834 Nov 29 20:55 lines2.png
-rw-r--r--   1 spotless  spotless   166 Nov 26 01:31 lines2.txt
-rw-r--r--   1 spotless  spotless  1033 Nov 29 00:45 lines3.bin
-rw-r--r--   1 spotless  spotless   616 Nov 29 20:55 lines3.png
-rw-r--r--   1 spotless  spotless   108 Nov 26 01:31 lines3.txt
-rw-r--r--   1 spotless  spotless   985 Nov 29 00:45 lines4.bin

lines4.bin does not have a .txt and .png version, we are most likely suppose to generate those ourselves.

File structure

File starts with a TiNyMeTa header and also seems to contain a PNG:

00000000: 5469 4e79 4d65 5461 0000 0010 0000 0002  TiNyMeTa........
00000010: 0008 0008 080c 0052 0002 0034 5478 5472  .......R...4TxTr
00000020: 0000 0301 8950 4e47 0d0a 1a0a 0000 000d  .....PNG........
00000030: 4948 4452 0000 0040 0000 0060 0103 0000  IHDR...@...`....
00000040: 0097 0be6 ab00 0000 0650 4c54 4500 0000  .........PLTE...
00000050: f0d1 c563 8e08 7e00 0002 b649 4441 5478  ...c..~....IDATx
00000060: da25 5241 641c 6114 feb6 7da6 1123 62c5  .%RAd.a...}..#b.
00000070: fa0f 2b5d 6bc5 1a3d 8c88 556b b322 a71c  ..+]k..=..Uk."..

Extracting it gives us a mapping of characters:

tail -c +37 lines4.bin > chars.png

https://i.imgur.com/4FdowA9.png

LiNe

At the bottom of the .bin file, we can observe:

00000310: 0707 9205 d0b7 2b6c e400 0000 0049 454e  ......+l.....IEN
00000320: 44ae 4260 824c 694e 6500 0000 3c05 0101  D.B`.LiNe...<...
00000330: 0b05 0607 0102 0704 0806 0704 0500 0904  ................
00000340: 0804 0205 0704 0801 0601 0b01 0305 0804  ................
00000350: 0805 0103 0a05 0804 0807 0404 0806 0205  ................
00000360: 0b03 0b01 0705 0806 074c 694e 6500 0000  .........LiNe...
00000370: 6805 0103 0a04 0806 0903 0700 0500 0a01  h...............
00000380: 0b00 0502 0704 0806 0707 0404 0806 0205  ................

Where LiNe is (possibly) locations to the chars found in the extracted PNG file.

We assume: LiNe<payload length><x,y><x,y><x,y>

Code

import struct

f = open("lines4.bin", "rb")
bindata = f.read()
f.close()

# from PNG
charmap = """
Q?0\\H$Y,
R-L^KJ*k
s#_/m=f9
7d-NE4qr
Pi*v`&XA
n3I'0*;Z
wGpB8cSj
Fg:eby"v
%+ 1 !M@
h{2xW.D}
tUICTz6u
Io>a5l<\'
""".strip().split("\n")

spl = bindata.split(b"LiNe")
flag = ""

for segment in spl[1:]:
    payload_length = struct.unpack(">L", segment[:4])[0]
    data = segment[4:][:payload_length]
    coords = [(ord(data[z]), ord(data[z+1])) for z in range(0, payload_length, 2)]

    for x, y in coords:
        char = charmap[y][x]
        flag += char

print(flag)

Output:

Jock: "0h my God! JC! A flag!"
JC Denton: "A flag! A0TW{wh4t_4_r0tt3n_fi13_f0rm4t}"

Flag

A0TW{wh4t_4_r0tt3n_fi13_f0rm4t}